<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page import="java.util.ArrayList,edu.student.models.*, com.opensymphony.xwork2.ActionContext" %>

<html>
<script language="JavaScript" type="text/javascript">
function doValidation() {
	var name=document.getElementById("name").value;
	var is_current=document.getElementById("is_current").value; 
	//var interest=document.getElementById("interest").value;
	//var duration=document.getElementById("duration").value;
	if (name==""){
		alert("Name field is manadtaory.Please enter appropriately");
		return false;
	}
/* 	if(duration==""){
			alert("Duration field is manadtaory.Please enter appropriately");
			return false;
		}  */
	if (is_current==""){
		alert("Is Current? field is manadtaory.Please enter appropriately");
		return false;
	}/* 
	var then = new Date(decodeURIComponent(duration));
	 var now = new Date();
	 if (now.getTime() > then.getTime()) { 
	alert("Duration should be more than current date");
	return false;
	 } */
	return true;
}
/* function doInterestValidation() {
	var interest=document.getElementById("interest").value;
	if(interest==""){
		alert("Interest field is manadtaory.Please enter appropriately");
		return false;
	} 
} */
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Modify lookup value</title>
<link rel="stylesheet" href="mystyle.css">
</head>

<body>
<h1 align="left">Modify the Lookup <%=ActionContext.getContext().getSession().get("table") %></h1> 

<s:form action="modify_lookup" align="left">
<s:hidden name="table" value="%{lookup.table}"/>
<s:hidden name="lookup_id" value="%{lookup.id}"/>
<table id="text" align="center">
<tr>
<td><s:textfield  label="Name" name="name" id="myinput" value="%{lookup.name}"/> </td>
</tr>
<s:if test="%{table=='announcement' || table=='news'}">
<tr>
 <td><s:select label="Select Interests" headerKey="" headerValue="" list="interestList" listvalue="name" name="interest" id="interest" value="%{lookup.interest}"></s:select></td>
 <td><s:textfield  label="Duration [yyyy-mm-dd]" name="duration" id="myinput" value="%{lookup.duration}"/> </td>
</tr>
</s:if>
<s:if test="%{table=='subject'}">
<tr>
 <td><s:textfield  label="Subject Code" name="subject_code" id="subject_code" value="%{lookup.subject_code}"/></h2> </td>
</tr>
<tr>
 <td><s:select label="Select Faculty" headerKey="" headerValue="" list="facultyList" listvalue="name" name="faculty" id="faculty"></s:select></td>
</tr>
</s:if>
<tr>
<td><s:select label="Is current?" headerKey="" headerValue="" name="is_current" list="#{'y':'yes', 'n':'no'}" value="%{lookup.is_current}" />
</tr>
<td>
<s:submit name ="submit" value="Modify" id="mysubmit" align="center" onClick="return doValidation()" />
</td>
<td>
</td>
</table>
</s:form>

</body>
</html>